/*
 * @Date: 2023-08-03 17:13:25
 * @LastEditors: lyx
 * @LastEditTime: 2023-11-03 13:47:54
 * @FilePath: \sup-mimi-program-server\libs\db\src\db.module.ts
 * @Description:
 */
import { Global, Module } from '@nestjs/common';
import { TypegooseModule } from 'nestjs-typegoose';
import { Post } from 'src/posts/entities/post.entity';
import { Weapp } from 'src/weapp/entities/weapp.entity';
import { Feishu_Tenant } from 'src/feishu/entities/feishu_tenant.entity';
import { DbService } from './db.service';

const models = TypegooseModule.forFeature([Feishu_Tenant, Post, Weapp]);

@Global()
@Module({
  imports: [
    TypegooseModule.forRootAsync({
      useFactory() {
        return {
          uri: process.env.mongodb,
        };
      },
    }),
    models,
  ],
  providers: [DbService],
  exports: [DbService, models],
})
export class DbModule {}
